library(gt)
library(kableExtra)
library(gtsummary)

plots_figs_folder <- "figures/paper_plots"
input_file <- "data/local_candidates.csv"

output_file <- "candidate_char_table.png"
output_file_latex <- "candidate_char_table.tex"

local_cands <- read.csv(input_file)

# 
# gt_table <- gt(local_cands) %>% 
#   tab_style(list(cell_fill(color = "red", alpha = 0.1)),
#             locations = cells_body(columns = c(3, 4),
#                                    rows = c(2, 3, 4))) %>% 
#   cols_label(Candidate.Type = "Candidate Type",
#              Born.in.Prefecture = "Born in Prefecture",
#              University.in.Prefecture = "University in Prefecture",
#    
#                       Both = "Both")
# gt_small_table <- local_cands %>% 
#   filter(!Candidate.Type %in% c("LDP", "JCP", "DPJ")) %>% 
#   gt() %>% 
#   tab_style(list(cell_fill(color = "red", alpha = 0.1)),
#             locations = cells_body(columns = c(3, 4),
#                                    rows = c(2, 3, 4))) %>% 
#   cols_label(Candidate.Type = "Candidate Type",
#              Born.in.Prefecture = "Born in Prefecture",
#              University.in.Prefecture = "University in Prefecture",
#              Both = "Both")

#gt_table %>% 
#  gtsave(file.path(plots_figs_folder, output_file))

#gt_table %>% 
#  gtsave(file.path(plots_figs_folder, output_file_latex))

#gt_small_table %>% 
#  gtsave("Perception of Elites/tables/cand_table_small.png")



print(kableExtra::kable(local_cands, 
                  col.names = c(Candidate.Type = "Candidate Type",
                                Born.in.Prefecture = "Born in Prefecture",
                                University.in.Prefecture = "University in Prefecture",
                                Both = "Both"),
                  format = "latex",
                  booktabs = TRUE))
